package cn.com.stary1993.kite.captcha.support.behavior;

import lombok.Getter;

/**
 * 验证码图片类型
 *
 * @author stary1993
 */
@Getter
public enum BehaviorImageCaptchaFormat {

    /**
     * webp类型.
     */
    WEBP,
    /**
     * jpg+png类型.
     */
    JPEG_PNG;

    public static BehaviorImageCaptchaFormat getFormat(String bgImageFormat, String sliderImageFormat) {
        final String webp = "webp";
        final String jpeg = "jpeg";
        final String jpg = "jpg";
        final String png = "png";
        if (webp.equalsIgnoreCase(bgImageFormat) && webp.equalsIgnoreCase(sliderImageFormat)) {
            return WEBP;
        }
        if ((jpeg.equalsIgnoreCase(bgImageFormat) || jpg.equalsIgnoreCase(bgImageFormat))
                && png.equalsIgnoreCase(sliderImageFormat)) {
            return JPEG_PNG;
        }
        return null;
    }

}
